﻿<Window x:Class="SessionHunter.MainWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
		xmlns:converter="clr-namespace:SessionHunter.Converters"
		xmlns:MvvmLight="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
		xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
		Title="Session Hunter"
		Height="600"
		Width="1000"
		DataContext="{Binding Main, Source={StaticResource Locator}}">

	<Window.Resources>
		<ResourceDictionary>
			<converter:BoolToOppositeBoolConverter x:Key="oppositeConverter"/>
			<converter:GreaterThanZeroConverter x:Key="greaterThanZeroConverter"/>
			<Storyboard x:Key="btnReferences_Attention">
				<DoubleAnimation 
					x:Name="btnReferences_Attention_Start"
					Storyboard.TargetName="btnReferences"
					Storyboard.TargetProperty="Opacity"
					From="1"
					To="0.25"
					RepeatBehavior="4x"
					AutoReverse="True"
					Duration="0:0:0.2"/>				
			</Storyboard>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="/Styles/Controls.xaml"/>
			</ResourceDictionary.MergedDictionaries>            
		</ResourceDictionary>
	</Window.Resources>

	<i:Interaction.Triggers>
		<i:EventTrigger EventName="Loaded">
			<MvvmLight:EventToCommand Command="{Binding Command_ViewLoaded}" />
		</i:EventTrigger>
	</i:Interaction.Triggers>

	<xctk:BusyIndicator x:Name="busyIndicator" IsBusy="{Binding Path=IsBusy}" BusyContent="{Binding Path=IsBusyMessage}" DisplayAfter="0">
		<TabControl SelectionChanged="TabControl_SelectionChanged">
			<TabItem Header="{Binding Tab_Session, Source={StaticResource LocStrings}}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="*"/>
						<RowDefinition Height="{Binding ErrorRowHeight}"/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="*"/>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition Width="295"/>
					</Grid.ColumnDefinitions>
					<GridSplitter HorizontalAlignment="Right" 
					  VerticalAlignment="Stretch" 
					  Grid.Column="1" 
					  ResizeBehavior="PreviousAndNext"
					  Width="5" Background="#FFBCBCBC"/>
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition />
							<ColumnDefinition />
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="60" />
							<RowDefinition Height="*"/>
							<RowDefinition Height="60" />
						</Grid.RowDefinitions>
						<Button x:Name="btnReferences" Content="{Binding Source={StaticResource LocStrings}, Path=Button_References}" Command="{Binding Command_References}" Width="130" Height="40" Margin="25,10,0,10" HorizontalAlignment="Left" Style="{DynamicResource RoundedButton}" BorderBrush="{StaticResource BlueButton}"></Button>
						<Button x:Name="btnRefresh" Content="{Binding Source={StaticResource LocStrings}, Path=Button_Refresh}" Command="{Binding Command_Refresh}" Width="130" Height="40" Margin="0,10,25,10" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Grid.Column="1" Style="{DynamicResource RoundedButton}" BorderBrush="{StaticResource BlueButton}"></Button>
						<Button x:Name="btnConnection" Content="{Binding Source={StaticResource LocStrings}, Path=Button_Connection}" Command="{Binding Command_Connection}" Width="130" Height="40" Margin="0,10,25,10" HorizontalAlignment="Right" HorizontalContentAlignment="Center" Grid.Column="1" Grid.Row="3" Style="{DynamicResource RoundedButton}" BorderBrush="{StaticResource BlueButton}"></Button>
						<ListView x:Name="listSession" ItemsSource="{Binding Path=Sessions}" IsEnabled="{Binding Path=HasSessions}" Loaded="listSession_Loaded" SelectionMode="Single" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
							<i:Interaction.Triggers>
								<i:EventTrigger EventName="SelectionChanged">
									<MvvmLight:EventToCommand 
													  Command="{Binding Command_ListSessionChanged}"
													  MustToggleIsEnabledValue="False" 
													  PassEventArgsToCommand="True"/>
								</i:EventTrigger>
							</i:Interaction.Triggers>
							<ListView.View>
								<GridView x:Name="gridViewSession"/>
							</ListView.View>
						</ListView>
					</Grid>
					<ListView x:Name="listSessionItemList" ItemsSource="{Binding Path=SessionItems}" Grid.Column="2" IsEnabled="{Binding Path=SessionItems.Count, Converter={StaticResource greaterThanZeroConverter}}" Margin="0,60,0,0">
						<ListView.View>
							<GridView x:Name="gridViewSessionItemList">
								<GridViewColumn Header="Item" Width="235" DisplayMemberBinding="{Binding Path=DisplayKey}" />
								<GridViewColumn Header="Size (KB)" Width="60" DisplayMemberBinding="{Binding Path=Size}" />
							</GridView>
						</ListView.View>
					</ListView>
					<TextBox x:Name="tbError" Grid.Row="1" Grid.ColumnSpan="3" Style="{StaticResource TextBox_ErrorConsole}" Text="{Binding Path=ErrorText, Mode=OneWay}"  Margin="25,16,25,16"></TextBox>
				</Grid>
			</TabItem>
			<TabItem Header="{Binding Tab_Options, Source={StaticResource LocStrings }}">
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="119" />
						<ColumnDefinition Width="186" />
						<ColumnDefinition Width="62" />
						<ColumnDefinition Width="177" />
						<ColumnDefinition Width="*" />
					</Grid.ColumnDefinitions>
					<Grid.RowDefinitions>
						<RowDefinition Height="76" />
						<RowDefinition Height="119" />
						<RowDefinition Height="*" />
					</Grid.RowDefinitions>
					<!-- Borders around controls -->
					<Border Style="{StaticResource RoundedBorder}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2">
					</Border>
					<Border Style="{StaticResource RoundedBorder}" Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="2" Grid.RowSpan="2">
					</Border>
					<Border Style="{StaticResource RoundedBorder}" Grid.Row="1" Grid.ColumnSpan="2">
					</Border>
					<!-- Controls -->
					<TextBox x:Name="tbNumberOfSessions" Grid.Column="1" Margin="60,20,60,0" IsEnabled="{Binding ElementName=cbNumberOfSessionsAll, Path=IsChecked,Converter={StaticResource oppositeConverter}}" Text="{Binding Path=NumberOfSessions, Mode=TwoWay}" Height="24" VerticalAlignment="Top">
						<i:Interaction.Triggers>
							<i:EventTrigger EventName="LostFocus">
								<MvvmLight:EventToCommand Command="{Binding Command_NumberOfSessions}" CommandParameter="{Binding Text, ElementName=tbNumberOfSessions}"/>
							</i:EventTrigger>
						</i:Interaction.Triggers>
					</TextBox>
					<CheckBox x:Name="cbNumberOfSessionsAll" Grid.Column="1" Margin="60,50,60,0" Command="{Binding Command_ShowAllSessions}" Content="{Binding Source={StaticResource LocStrings}, Path=Setting_SessionAll}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" Height="26" VerticalAlignment="Top" />
					<Label Grid.Column="0" Grid.Row="0" Margin="5,5,0,0" Content="{Binding Setting_Label_Sessions, Source={StaticResource LocStrings }}" />
					<Label Grid.Row="1" Content="{Binding Setting_Label_OrderBy, Source={StaticResource LocStrings }}" Margin="5,5,0,0" Grid.RowSpan="2" Grid.ColumnSpan="2" Height="153" VerticalAlignment="Top" HorizontalAlignment="Left" Width="119" />
					<Label Grid.Column="2" Grid.Row="0" Margin="5,5,0,0" Content="{Binding Setting_Label_Columns, Source={StaticResource LocStrings }}" />
					<CheckBox x:Name="cbShowCreateExpires" Content="{Binding Settings_ShowCreateExpires, Source={StaticResource LocStrings }}" Command="{Binding Command_ShowCreateExpires}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" Grid.Column="3" Height="16" HorizontalAlignment="Left" Margin="25,30,0,0" VerticalAlignment="Top" />
					<CheckBox x:Name="cbShowLockInfo" Content="{Binding Settings_ShowLockInfo, Source={StaticResource LocStrings }}" Command="{Binding Command_ShowLockInfo}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" Grid.Column="3" Height="16" HorizontalAlignment="Left" Margin="25,60,0,0" VerticalAlignment="Top" />
					<CheckBox x:Name="cbShowApplication" Content="{Binding Settings_ShowApplication, Source={StaticResource LocStrings }}" Command="{Binding Command_ShowApplication}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" Grid.Column="3" Grid.Row="1" Height="16" HorizontalAlignment="Left" Margin="25,14,0,0" VerticalAlignment="Top" />
					<RadioButton x:Name="rbSessionOrderByLargest" GroupName="OrderBy" Content="{Binding Source={StaticResource LocStrings}, Path=Setting_OrderByLargestSession}" Command="{Binding Command_OrderBy}" CommandParameter="LargestSession" Grid.Column="1" Grid.Row="1" Margin="20,20,0,0" Grid.RowSpan="2" />
					<RadioButton x:Name="rbSessionOrderBySessionId" GroupName="OrderBy" Content="{Binding Source={StaticResource LocStrings}, Path=Setting_OrderBySessionId}" Command="{Binding Command_OrderBy}" CommandParameter="SessionId" Grid.Column="1" Grid.Row="1" Margin="20,40,0,0" Grid.RowSpan="2" />
					<RadioButton x:Name="rbSessionOrderByCreateDateMost" GroupName="OrderBy" Content="{Binding Source={StaticResource LocStrings}, Path=Setting_OrderByCreateDateMost}" Command="{Binding Command_OrderBy}" CommandParameter="CreateDateMostRecent" Grid.Column="1" Grid.Row="1" Margin="20,60,0,0" Grid.RowSpan="2" />
					<RadioButton x:Name="rbSessionOrderByCreateDateLeast" GroupName="OrderBy" Content="{Binding Source={StaticResource LocStrings}, Path=Setting_OrderByCreateDateLeast}" Command="{Binding Command_OrderBy}" CommandParameter="CreateDateLeastRecent" Grid.Column="1" Grid.Row="1" Margin="20,80,0,0" Grid.RowSpan="2" />
				</Grid>
			</TabItem>
		</TabControl>
	</xctk:BusyIndicator>
</Window>

	